package com.thwcompany.service.impl;
import com.thwcompany.pojo.Mail;
import com.thwcompany.service.ProducerModeService;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
//生产者-消费者模式
@Service
@Transactional
@SuppressWarnings("ALL")
public class ProducerModeServiceImpl implements ProducerModeService {
	@Autowired
	RabbitTemplate rabbitTemplate;
	//生产者直接向队列queue发送消息，没有用交换机，则会使用默认的direct.
	@Override
	public void sendMail(String queue, Mail mail) {
		//rabbitTemplate.setQueue(queue);
		rabbitTemplate.convertAndSend(queue,mail);
	}

}
